xend: Fix cleanup_domains() for suspending managed domains
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 12 Dec 2007 10:08:14 +0000 (10:08 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 12 Dec 2007 10:08:14 +0000 (10:08 +0000)
When unmanaged domains with on_xend_stop="suspend" exist, managed
domains are not suspended by xend stop command.  The processing of
cleanup_domains() is aborted by exception. This patch keeps suspending
managed domains even if unmanaged domains exist.

Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
tools/python/xen/xend/XendDomain.py

index 5af454afd0967bc8e7e1e4f449185d508ed96fb8..553a22d2c72f5426908511bd2ae9f73d0f71e8f4 100644 (file)
@@ -613,13 +613,19 @@ class XendDomain:
                 if dom.getName() == DOM0_NAME:
                     continue
                 
-                if dom._stateGet() == DOM_STATE_RUNNING:
-                    shutdownAction = dom.info.get('on_xend_stop', 'ignore')
-                    if shutdownAction == 'shutdown':
-                        log.debug('Shutting down domain: %s' % dom.getName())
-                        dom.shutdown("poweroff")
-                    elif shutdownAction == 'suspend':
-                        self.domain_suspend(dom.getName())
+                try:
+                    if dom._stateGet() == DOM_STATE_RUNNING:
+                        shutdownAction = dom.info.get('on_xend_stop', 'ignore')
+                        if shutdownAction == 'shutdown':
+                            log.debug('Shutting down domain: %s' % dom.getName())
+                            dom.shutdown("poweroff")
+                        elif shutdownAction == 'suspend':
+                            self.domain_suspend(dom.getName())
+                        else:
+                            log.debug('Domain %s continues to run.' % dom.getName())
+                except:
+                    log.exception('Domain %s failed to %s.' % \
+                                  (dom.getName(), shutdownAction))
         finally:
             self.domains_lock.release()